package com.suitsoft.ut.dao.base;

import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;
import org.springside.modules.orm.Page;
import org.springside.modules.orm.hibernate.HibernateDao;

import com.suitsoft.ut.commons.UserHolder;
import com.suitsoft.ut.entity.account.User;
import com.suitsoft.ut.entity.base.Teacher;

/**
 *
 *@author Suineg
 */
@Repository
public class TeacherDao extends HibernateDao<Teacher,Long>{
	/** 日志输出对象 */
	protected final Logger logger = LoggerFactory.getLogger(getClass());

	/**
	 * 根据教师获取账户信息
	 * @param userId
	 * @return
	 */
	public Teacher findByUser(Long id){
		String hql = "from Teacher as t inner join fetch t.forUser u where u.id =" + id;
		return findUnique(hql);
	}
	
	public Page<Teacher> findThesisByTeacher(Page<Teacher>page ,Long id){
		String hql = "select distinct ta from Teacher ta,Thsis t where ta.teacherNo = t.teacherNo and ta.id =" + id;
		return findPage(page, hql);
	}
	
	public Teacher findByTeacherNo(String tid){
		return findUniqueBy("teacherNo", tid);
	}
}

